package org.yzh.web.service.impl;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.yzh.web.mapper.AlarmMessageMapper;
import org.yzh.web.model.vo.*;
import org.yzh.web.service.AlarmMessageService;

import java.util.List;
import java.util.Map;

/**
 * @author lsj
 * @date 2021/1/15 22:02
 */
@Service
public class AlarmMessageServiceImpl implements AlarmMessageService {
    @Autowired
    private AlarmMessageMapper alarmMessageMapper;
    @Override
    public List<AlarmMessage> find(AlarmMessageQuery query) {
        return alarmMessageMapper.find(query);
    }

    @Override
    public AlarmCountTotal findAlarmCountTotal(AlarmMessageQuery query) {
        List<AlarmGroup> data = alarmMessageMapper.findAlarmCountTotal(query);
        AlarmCountTotal alarmCountTotal = new AlarmCountTotal();
        for (AlarmGroup alarmGroup : data) {
            switch (alarmGroup.getType()) {
                case 0x01:
                    alarmCountTotal.setFcwCount(alarmGroup.getCount());
                    break;
                case 0x03:
                    alarmCountTotal.setHmwCount(alarmGroup.getCount());
                    break;
                case 0x04:
                    alarmCountTotal.setPcwCount(alarmGroup.getCount());
                    break;
                case 0x08:
                    alarmCountTotal.setUfcwCount(alarmGroup.getCount());
                    break;
                case 0x09:
                    alarmCountTotal.setLdwlCount(alarmGroup.getCount());
                    break;
                case 0x0a:
                    alarmCountTotal.setLdwrCount(alarmGroup.getCount());
                    break;
                default:
                    break;
            }
        }
        return alarmCountTotal;
    }
}
